import datetime

from sqlalchemy import Column, Integer, String, Float, DateTime, UniqueConstraint, ForeignKey, Text

from QualityInspectionViolation.DbInit.mysqlDb import Base


class ShareRecording(Base):
    __tablename__ = 'share_recording'
    id = Column(Integer, primary_key=True)
    soundRecordingIdList = Column(Text)
    type = Column(Integer)
    shareWithId = Column(String(255))
    shareWithName = Column(String(32))
    createdAt = Column(DateTime, default=datetime.datetime.now)
    updatedAt = Column(DateTime, default=datetime.datetime.now)

    def insertShareRecording(self, shareRecording, session):
        session.add(shareRecording)

    def queryShareRecording(self, shareRecordingId, session):
        shareRecording = session.query(ShareRecording).\
            filter(ShareRecording.id == shareRecordingId).first()
        return shareRecording